#爬html文档，图片，视频，音频，json文件

import requests as req
import json
header={"user-agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36 Edg/138.0.0.0"}
res1=req.get(url="https://www.bilibili.com/",headers=header)
with open("./html/01.html","w",encoding="utf-8") as fp1:
    fp1.write(res1.content.decode("utf-8"))#爬取html

res2=req.get(url="https://i1.hdslb.com/bfs/banner/5593f9d7f153e2696bf0d80345752702b0ac9102.png@800w_512h_!web-home-carousel-cover",headers=header)
with open("./img/01.png","wb") as fp2:
    fp2.write(res2.content)#爬取图片

res3=req.get(url="https://videos.pexels.com/video-files/13964913/13964913-uhd_1440_2560_30fps.mp4",headers=header)
with open("./mp4/01.mp4","wb") as fp3:
    fp3.write(res3.content)#爬取视频

res4 = req.get(url="https://webfs.kugou.com/202508061546/581af8ccace148202a9165bffb616322/v3/5dc6bbee1bf3afb0c4219e6ada0e500d/yp/full/ap1014_us2174988667_mii0w1iw8z2ai2iphcu80ooo2ki81120_pi406_mx779542415_s3088101432.mp3", headers=header)
with open("./mp3/01.mp3", "wb") as fp4:
    fp4.write(res4.content)  # 爬音频

res5 = req.get(url= "https://movie.douban.com/j/chart/top_list?type=24&interval_id=100%3A90&action=&start=0&limit=20",headers=header)

movies=json.loads(res5.content.decode("utf-8"))
with open("./txt/01.txt","at") as fp5:
    for movie in movies:
        fp5.write(movie["title"])
        fp5.write("\n")
